﻿using JmShared;
using SuperWebSocket.SubProtocol;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebSocketServer.Filters;

namespace WebSocketServer.Commands
{
    [LogTimeCommandFilter(Order = 0)]
    public class ResetPassword : JsonSubCommand<JiveClientSession, PasswordReset>
    {

        protected override void ExecuteJsonCommand(JiveClientSession session, PasswordReset pr)
        {
            var result = DB.DbManager.ChangePassword(pr.UserName, pr.VerificationToken, pr.NewPassword);
            SendJsonMessage(session, new DatabaseQueryResponse(result.Success, result.StatusText));
        }
    }
}
